package io.awen.modules.sign.controller;

import io.awen.common.utils.PageUtils;
import io.awen.common.utils.R;
import io.awen.modules.sign.entity.SignUnitEntity;
import io.awen.modules.sign.qo.SignUnitQo;
import io.awen.modules.sign.service.SignUnitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;


/**
 * 收运单位表(收运车辆所属单位)
 *
 * @author liu.wen
 * @email liu.wen@qq.com
 * @date 2022-08-10 00:47:08
 */
@Api(tags = {"运维单位"})
@RestController
@RequestMapping("sign/signunit")
public class SignUnitController {
    @Autowired
    private SignUnitService signUnitService;

    /**
     * 列表
     */
    @ApiOperation("分页查询")
    @RequestMapping("/list")
//    @RequiresPermissions("sign:signunit:list")
    public R list(@RequestBody SignUnitQo qo) {

        PageUtils page = signUnitService.queryPage(qo);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sign:signunit:info")
    public R info(@PathVariable("id") Long id) {
        SignUnitEntity signUnit = signUnitService.getById(id);

        return R.ok().put("signUnit", signUnit);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sign:signunit:save")
    public R save(@RequestBody SignUnitEntity signUnit) {
        signUnitService.save(signUnit);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sign:signunit:update")
    public R update(@RequestBody SignUnitEntity signUnit) {
        signUnitService.updateById(signUnit);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sign:signunit:delete")
    public R delete(@RequestBody Long[] ids) {
        signUnitService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
